<template>
	<view class="container">
		<view class="" class="list" v-for="(item,index) in dataList" :key="index" @click="goToDetail(item.type)"
			:style="{'background':bacg}">
			{{item.dataName}}
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				dataList: [{
					dataName: '地图使用',
					type: 'useMap'
				}, {
					dataName: '登陆授权'
				}],
				bacg: ''
			}
		},
		onShow() {
			this.bacg = this.randomColor()
		},
		methods: {
			goToDetail(type) {
				switch (type) {
					case 'useMap':
						uni.navigateTo({
							url: '/subPages/demoSub/useMap'
						})
				}
			},

			getRandomBetween(min, max) {
				return Math.floor(Math.random() * (max - min + 1)) + min
			},

			randomColor() {
				return `#${this.getRandomBetween(1,255).toString(16)}${this.getRandomBetween(1,255).toString(16)}${this.getRandomBetween(1,255).toString(16)}`
			}
		}
	}
</script>

<style>
	.container {
		padding: 20rpx;
	}

	.list {
		padding: 20rpx;
		text-align: center;
		background-color: deepskyblue;
		margin-bottom: 20rpx;
		border-radius: 10rpx;
	}
</style>
